package galleryviewer.data;

import java.util.List;

/**
 * Stores the local data content parsed from xml config
 * @author jaccus
 */
public class LocalBean {

    private long id;
    private String name;
    private String imageurl;
    private List<String> keywords;
    private String description;

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public String getImageurl() {
        return imageurl;
    }

    public void setImageurl(String imageurl) {
        this.imageurl = imageurl;
    }

    public List<String> getKeywords() {
        return keywords;
    }
    
    public String getKeywordsString() {
    	StringBuilder keywordsString = new StringBuilder();
    	
    	for (int i = 0; i < keywords.size(); i++) {
    		String keyword = keywords.get(i);
    		
    		keywordsString.append(keyword);
    		
    		boolean isLastElement = i == keywords.size()-1;
    		
			if (!isLastElement) {
				keywordsString.append(", ");
			}
		}
    	
    	return keywordsString.toString();
    	
    }
    
    public boolean keywordsContain(String keyword) {
    	for (String _keyword : keywords) {
			if(_keyword.equals(keyword)) {
				return true;
			}
		}
    	return false;
    }

    public void setKeywords(List<String> keywords) {
        this.keywords = keywords;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "local[id="+id+"][name="+name+"][imageurl=["+imageurl+"][desc="+description+"][keywords"+keywords+"]";
    }

    
}
